package com.stone.starter.core.helper;

import com.stone.starter.core.operation.Operation;
import com.stone.starter.core.operation.OperationT;
import org.springframework.transaction.annotation.Transactional;

/**
 * 事务操作帮助类
 *
 * @author Mr_wenpan@163.com 2021/07/15 10:24
 */
public class TransactionalHelper {

    @Transactional(rollbackFor = Exception.class)
    public void transactionOperation(Operation operation) {
        operation.execute();
    }

    @Transactional(rollbackFor = Exception.class)
    public <T> T transactionOperation(OperationT<T> operation) {
        return operation.execute();
    }

}
